package com.xinbochuang.machine.admin.controller;


import com.xinbochuang.machine.admin.domain.AlarmCount;
import com.xinbochuang.machine.admin.domain.CameraInoutRecord;
import com.xinbochuang.machine.admin.service.ICameraInoutRecordService;
import com.xinbochuang.machine.common.controller.BaseController;
import com.xinbochuang.machine.common.domain.TableDataInfo;
import com.xinbochuang.machine.framework.web.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 杜文博
 * @date 2020-10-29
 */
@RestController
@RequestMapping("/camera-inout-record")
public class CameraInoutRecordController extends BaseController {

    @Autowired
    private ICameraInoutRecordService iCameraInoutRecordService;

    /**
     * 根据cameraId分页查询机房人员进出记录
     *
     * @param cameraInoutRecord
     * @return
     */
    @GetMapping("/list")
    public TableDataInfo getCameraAlarmList(CameraInoutRecord cameraInoutRecord) {
        return getDataTable(iCameraInoutRecordService.getCameraInoutListByCameraId(cameraInoutRecord));
    }

    /**
     * 进出统计
     */
    @GetMapping("/inoutCount")
    public AjaxResult inoutCount() {
        AjaxResult ar = AjaxResult.ok();
        int total = iCameraInoutRecordService.selectInoutCountToday();
        // 自有人员
        List<AlarmCount> selfList = iCameraInoutRecordService.inoutCount(3);
        // 第三方人员
        List<AlarmCount> otherList = iCameraInoutRecordService.inoutCount(5);
        ar.put("total", total);
        ar.put("selfList", selfList);
        ar.put("otherList", otherList);
        return ar;
    }

}

